package com.yphone.ui.pay.model;

import com.google.gson.reflect.TypeToken;
import com.yphone.net.HttpConstants;
import com.yphone.net.IUIDataListener;
import com.yphone.net.bean.BaseResultWrapper;
import com.yphone.net.helper.ActivityHttpHelper;
import com.yphone.ui.login.manager.LoginManager;
import com.yphone.ui.pay.bean.CheckOrderInfo;
import com.yphone.ui.pay.contract.OrderContract;

import java.util.HashMap;

public class OrderModel implements OrderContract.IModel {

    @Override
    public void getQRCode(IUIDataListener listener,String serverId,String orderNo,int num) {
        ActivityHttpHelper<BaseResultWrapper<String>> helper = new ActivityHttpHelper<>(new TypeToken<BaseResultWrapper<String>>() {
        });
        HashMap<String, String> map = new HashMap<>();
        map.put("token", LoginManager.getInstance().getToken());
        map.put("servier_id",serverId);
        map.put("orderNo",orderNo);
        map.put("num",num+"");
        helper.UpdateUIDataListener(listener);
        helper.sendPostRequest(HttpConstants.createScanPayQrCodeBase64+"/"+orderNo+"/"+serverId,map,HttpConstants.TIME_OUT3);
    }

    @Override
    public void checkOrderState(IUIDataListener listener,String orderNo) {
        ActivityHttpHelper<BaseResultWrapper<CheckOrderInfo>> helper = new ActivityHttpHelper<>(new TypeToken<BaseResultWrapper<CheckOrderInfo>>() {
        });
        HashMap<String, String> map = new HashMap<>();
        map.put("token", LoginManager.getInstance().getToken());
        map.put("orderNo",orderNo);
        helper.UpdateUIDataListener(listener);
        helper.sendPostRequest(HttpConstants.checkWxQrCodeState,map,HttpConstants.TIME_OUT3);
    }
}
